package com.novabluetooth.adapter;

import java.text.SimpleDateFormat;
import java.util.List;

import com.health.R;
import com.novabluetooth.services.ktxyj.DeviceDataXueYang;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class XueYangAdapter extends BaseAdapter {
	private List<DeviceDataXueYang> list;
	private Context mContext;
	private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public XueYangAdapter(Context mContext,List<DeviceDataXueYang> list) {
		this.mContext=mContext;
		this.list= list;
		System.out.println(list.size()+"**********-----------------------/////////////");
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh;
		if (convertView == null) {
			System.out.println("血氧列表");
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.sbcl_xyang_listitem, null);
			vh = new ViewHolder();
			findView(vh, convertView);
			convertView.setTag(R.id.TAG_VIEWHOLDER, vh); 
		} else
			vh = (ViewHolder) convertView.getTag(R.id.TAG_VIEWHOLDER);

		setData(vh, convertView, position);

		return convertView;
	}
	private void setData(ViewHolder h, View v, int position) {
		h.xy.setText("血氧："+list.get(position).getXueYang()+"%");
		h.ml.setText("脉率："+list.get(position).getMaiLv()+"次/分");
		h.clsj.setText("测量时间："+dateFormat.format(list.get(position).getmSaveDate()));
		
	}
	private void findView(ViewHolder h, View v) {
		h.xy=(TextView) v.findViewById(R.id.tv_xy);
		h.ml=(TextView) v.findViewById(R.id.tv_ml);
		h.clsj= (TextView) v.findViewById(R.id.tv_clsj);
	}
	private static class ViewHolder {
		TextView xy;
		TextView ml;
		TextView clsj ;
	}

}
